package com.android.demo.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Shader;
import android.view.View;

public class Mask extends View{

    private int width, higth;
    @Override
    protected void onDraw(Canvas canvas) {

        // 生成可以绘制透明渐变的矩形View的画笔
        Paint paint = new Paint();
        Shader mShader=new LinearGradient(50,50,50,200,
                new int[]{Color.argb(0, 255, 255, 255),Color.WHITE},
                null,Shader.TileMode.CLAMP);
        paint.setShader(mShader);
        
        // 以绘制透明渐变的矩形View
        Rect rect = new Rect();
        rect.set(0, 0, width, higth);
        canvas.drawRect(rect, paint);
    }
    
    public Mask(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }
    
    public Mask(Context context, int width, int higth) {
        super(context);
        this.higth = higth;
        this.width = width;
    }
}